package com.jiang.mvc.dao;

import com.jiang.mvc.bean.User;
import com.jiang.util.JdbcUtilDateSource;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;


public class UserDao {
    public User loginDao(String zhanghao){
        User user=null;

        try {
            Connection conn = JdbcUtilDateSource.getCoon( );
            String sql="select * from hao where zhanghao=?";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString (1,zhanghao);
            ResultSet rs = ps.executeQuery ( );
            if (rs.next ()){
                user = new User( );
                user.setId("id");
                user.setZhanghao(rs.getString("zhanghao"));
                user.setMima(rs.getString("mima"));

            }
            rs.close ();
            ps.close ();
            conn.close ();
        } catch (Exception e) {
            e.printStackTrace ( );

        }
        return user;

    }
}